# _*_ coding : utf-8 _*_
# @Time : 2022/9/14 17:01
# @Author : Moonquake
# @File : test
# @Project : base.py
import time
from threading import Thread,Lock
from queue import Queue

lock = Lock()
info = Queue()

class Boss(Thread):
    def run(self) -> None:
        for i in range(100):
            info.put(i)


class Work(Thread):
    def run(self) -> None:
        while True:
            job = info.get()
            time.sleep(1)
            lock.acquire()
            print(job)
            lock.release()
            info.task_done()


b=Boss()
b.daemon =True
b.start()

for _ in range(10):   # _下划线为临时变量
    w=Work()
    w.daemon = True
    w.start()

info.join()